package cate.game.play.skill.active;

import cate.common.annotation.SplitParse;
import cate.common.util.SplitParser;
import cate.common.util.XT;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.proce.action.ctx.SkillActionCtx;

import java.util.List;

/**
 * 对敌方单体造成3次各162%的物理伤害，每2层【绝杀之刃】额外增加1次斩击(最多2次，即5连击)，
 */
public class 锋芒毕露AH extends ActiveHandler{

	private String buff标签;

	private List<Config> 技能配置;

	//buff标签=绝杀之刃&技能配置=0:??#2:??#4:??  （配置对应层数的技能id）
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		buff标签 = args.get("buff标签");
		技能配置 = SplitParser.parse(Config.class,args.get("技能配置"));
	}

	@Override
	public void onSkillDone(SkillActionCtx action) {
		int buffNum = skill.owner.buff.countBuffByTag(buff标签);
		int brotherSkill = getSkillTid(buffNum);
		action.getMove().param.addBrotherSkill(action.getSkill().tid,brotherSkill);
	}

	private int getSkillTid(int buffNum) {
		int skillTid = -1;
		if (XT.isNotBlank(技能配置)) {
			for (Config cfg : 技能配置) {
				if (buffNum >= cfg.buffNum) {
					skillTid = cfg.skillTid;
				}
			}
		}
		return skillTid;
	}

	public static class Config {

		@SplitParse(order = 0,defaultValue = "0")
		public int buffNum;

		@SplitParse(order = 1,defaultValue = "0")
		public int skillTid;
	}
}
